<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>老师测验章节批改管理测验章节列表页</title>
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" type="text/css" href="../css/api.css"/>
		<link rel="stylesheet" href="../../css/aui.css">
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/personal.css">
		<style>
			body {
				background: #FFFFFF;
				margin: 0px;
			}
			.mask {
				position: absolute;
				top: 0px;
				filter: alpha(opacity=60);
				background-color: #777;
				z-index: 1002;
				left: 0px;
				opacity: 0.5;
				-moz-opacity: 0.5;
			}
			.marklist {
				width: 25%;
				font-size: 75%
			}
			.win_bar_bot {
				width: 100%;
				height: 40px;
				position: absolute;
				top: 44px;
			}
			.top_bar {
				background: #18b4ed;
				width: 100%;
				height: 40px;
				display: -webkit-box;
			}
			.top_bar_center {
				width: 100%;
				padding: 10px;
				height: 25px;
			}
			.bar_zw {
				width: 75%;
				height: 18px;
			}
			.bar_td {
				width: 100%;
				height: 18px;
				display: -webkit-box;
				line-height: 18px;
				text-align: -webkit-center;
				-webkit-appearance: none !important;
				-moz-appearance: none !important;
				-webkit-border-radius: 0;
				-webkit-appearance: listbox;
				/*background: #fff url('') no-repeat 98% center;*/
			}
			.bar {
				width: 33.3%;
				height: 18px;
				border-style: solid;
				border-width: 0px 0px 0px 1px;
				border-color: #FFFFFF;
			}
			.bar_one {
				width: 33.3%;
				height: 18px;
				border-style: solid;
				border-width: 0px 0px 0px 0px;
				border-color: #FFFFFF;
			}
			.bar_text {
				color: #FFFFFF;
				font-size: 15px;
				text-align: center;
				vertical-align: middle;
				display: -webkit-inline-box;
				-webkit-margin-before: 0em;
				-webkit-margin-after: 0em;
				-webkit-margin-start: 0px;
				-webkit-margin-end: 0px;
			}
			.button_red {
				color: #F64E4E;
			}
			.button_blue {
				color: #18B4ED;
			}
			tr {
				width: 100%;
				height: 35%;
			}
			table {
				background: #7cd0ee;
				width: 100%;
				height: 40px;
				position: inherit;
				margin: auto;
				border-spacing: 0px;
			}
			.aui-list.aui-list-in .aui-list-item {
				background-position: 0 bottom;
			}
		</style>
	</head>
	<body>
		<div id='mian'>
			<!--	<table>
			<tr>
			<td class="bar_one">
			<div class="bar_td" >
			<p class="bar_text" id="qu_fx">
			姓名
			</p>
			</div></td>
			<td class="bar">
			<div class="bar_td" >
			<p class="bar_text" id="qu_fx">
			得分
			</p>
			</div></td>
			<td class="bar">
			<div class="bar_td" >
			<p class="bar_text" id="qu_fx">
			操作
			</p>
			</div></td>
			</tr>
			</table>-->
			<div class="aui-content aui-margin-b-15 ">
				<ul class="aui-list aui-list-in" id="quar_list">
					<!--<li    class="aui-list-item certification" onclick="itemclicl(' + i + ',' + data.studyid + ',' + data.cjid + ',' + data.tid + ')">
					<div class="aui-list-item-inner">
					<div class="aui-list-item-title" style="width: 25%;text-align: center">
					6
					</div>
					<div class="aui-list-item-text left_10 " style="width: 20%;text-align: center">
					56分
					</div>
					<div class="aui-info-item  button_blue"  style="width: 18%;text-align: center;">
					已阅
					</div>
					</div>
					</li>-->
				</ul>
			</div>
			<div id="mask" class="mask"></div>
			<div class="noSign" hidden="hidden" id="noData">
				<img src="../../image/icon_img.png" width="60%">
				<p class="font16 top_15 base_dark_grey" >
					暂无数据
				</p>
			</div>
			<div class="loadFailure" hidden="hidden" id="noNet">
				<img src="../../image/icon_img01.png" width="60%">
				<p class="" >
					数据加载失败
				</p>
				<p>
					请检查您的网络
				</p>
				<button type="button"  onclick="loadChapterData()"class="mui-btn mui-btn-outlined">
					重新加载
				</button>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript">
		var quar_list = [];
		var currentStudents;
		var page = 1;
		var rows = 20;
		var refreshCount = 0;
		var classid = "";
		var testtype = "";
		var yes_Arr = new Array();
		var no_Arr = new Array();
		var firstLoad = true;
		var firstLoadType = false;
		//新请求到的数据条数
		apiready = function() {
			showProgress();
			setRefreshHeader();
			setPullUpRefresh();
			ReceNotifi();
			loadNewData();
			$("#mask").click(function() {
				$("#mask").hide();
				api.sendEvent({
					name : 'close_mask'
				});
			});
		}
		//下拉刷新
		function setRefreshHeader() {
			api.setRefreshHeaderInfo({
				visible : true,
				bgColor : '#ccc',
				textColor : '#fff',
				textDown : '下拉刷新...',
				textUp : '松开刷新...',
				showTime : true
			}, function(ret, err) {
				loadNewData();
			});
		}

		// 上拉加载
		function setPullUpRefresh() {
			api.addEventListener({
				name : 'scrolltobottom'
			}, function(ret, err) {
				if (refreshCount >= rows) {
					loadMoreData();
				}
			});
		}

		function ReceNotifi() {
			api.addEventListener({
				name : 'mark_show'
			}, function(ret, err) {
				$("#mask").css("height", $(document).height());
				$("#mask").css("width", $(document).width());
				$("#mask").show();
			});
			api.addEventListener({
				name : 'RefreshTestListNotifi'
			}, function(ret, err) {
				//coding...
				loadNewData();
			});
			//关闭蒙版
			api.addEventListener({
				name : 'mark_close'
			}, function(ret, err) {
				//coding...
				//关闭蒙层
				$("#mask").hide();
			});
			//分类
			api.addEventListener({
				name : 'item_point'
			}, function(ret, err) {
				if (ret) {
					var data = ret.value.data;
					var type = ret.value.type;
					if (type == 0) {//类型
						classid = data.id;
						showProgress();
						loadNewData();
					} else if (type == 1) {//方向
						testtype = strGetStaus(data.name);
						showProgress();
						loadNewData();
					}
				}
			});
		}

		function loadNewData() {
			page = 1;
			loadChapterData();
		}

		function loadMoreData() {
			page++;
			loadChapterData();
		}

		function strGetStaus(str) {
			if (str == '全部') {
				return '';
			} else if (str == '已批') {
				return '1';
			} else if (str == '未批') {
				return '0';
			}
		}

		//获取班级学生列表
		function loadChapterData() {
			if (firstLoad == true) {
				api.showProgress({
					style : 'default',
					animationType : 'fade',
					title : '加载中...',
					text : '',
					modal : false
				});
				firstLoad = false;
			}
			//			var url = "http://base.cfnet.org.cn/course/test/getTestList?uid=" + $api.getStorage('cfnetppuid') + "&jid=" + $api.getStorage('cfnetppjxid') + "&vid=" + api.pageParam.vid + "&cid=" + api.pageParam.cid + "&pid=" + api.pageParam.pid + "&status=" + testtype + "&page=" + page + "&rows=" + rows + "&classid=" + classid;
			var params = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				vid : api.pageParam.vid,
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
				status : testtype,
				page : page,
				rows : rows,
				classid : classid,
			}
			cfnetppPOST(url_getTestList, params, true, function(data, status) {
//																alert(JSON.stringify(params)+'/n'+JSON.stringify(data))
				//								alert(JSON.stringify(data))
				api.refreshHeaderLoadDone();
				api.hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						if (page == 1) {
							firstLoadType = true
						}
						var dataArray = data.data;
						var students = dataArray.list;
						if (students != '' && students.constructor == Array && students.length > 0) {
							refreshCount = students.length;
							currentStudents = students;
							quar_list = currentStudents;
							writelist(students,students.length);
							sendEvent(dataArray.z_num, refreshCount, unique(no_Arr), unique(yes_Arr));
							$('#noData').hide();
							$('#noNet').hide();
						} else {
							$('#noData').show();
							$('#noNet').hide();
						}
					} else if (data.code == 108) {
						if (page == 1) {
							//						 alert(refreshCount)
							$('#quar_list').html('');
							$('#noData').show();
							$('#noNet').hide();
						} else {
						   api.refreshHeaderLoadDone();
						    ShowToast('我是有底线的')
							$('#noData').hide();
							$('#noNet').hide();
						}
					} else {
					}
				} else {
					//					alert('没网了');
					$('#quar_list').html('');
					$('#noData').hide();
					$('#noNet').show();
				}
			});
		}

		function sendEvent(z_num, s_num, no_num, yes_num) {
			api.sendEvent({
				name : 'item_pie',
				extra : {
					z_num : z_num,
					s_num : s_num,
					no_num : no_num,
					yes_num : yes_num,
				}
			});
		}

		function writelist() {
			var data = '';
			var strhtml = '';
			var Is_yuejuan = '';
			var typeStr = '';
			for (var i = 0; i < quar_list.length; i++) {
				data = quar_list[i];
				var score = data.score + '分';
				if (data.Is_yuejuan == 0) {
					no_Arr.push(i);
					typeStr = '<div class="aui-info-item button_red"  style="width: 18%;text-align: center;">未批' + '</div>';
				} else if (data.Is_yuejuan == 1) {
					yes_Arr.push(i);
					typeStr = '<div class="aui-info-item  button_blue"  style="width: 18%;text-align: center;">已批' + '</div>';
				}
				var DataArr=JSON.stringify(data).replace(/"/g, '&quot;');
				var str = '<li    class="aui-list-item certification" onclick="itemclicl(' +DataArr + ')">' + '<div class="aui-list-item-inner">' + '<div class="aui-list-item-title" style="width: 25%;text-align: center">' + data.rename + '</div>' + '<div class="aui-list-item-text left_10 " style="width: 20%;text-align: center">' + score + '</div>' + typeStr + '</div>' + '</div>' + '</li>';
				strhtml = strhtml + str;
			}
			if (page == 1) {
				$('#quar_list').html(strhtml);
			} else {
				$('#quar_list').append(strhtml);
			}
		}
		
		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
				vid : api.pageParam.vid,
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}

		function itemclicl(data) {
			if (api.pageParam.type == 0) {//mocc
				sendBuriedNotifi('1', 'MOOC测验老师批阅列表', '014');
			} else {
			   sendBuriedNotifi('1', '自由课程测验老师批阅列表', '056');
			}
//			var dataArr = quar_list[i];
			var dataArr = data;
			var type = dataArr.Is_yuejuan;
			var rename = dataArr.rename;
			var cuid=dataArr.studyid;
			var cjid=dataArr.cjid;
			var tid=dataArr.tid;
			if (type == 0) {
				api.openWin({useWKWebView:true,
					name : 'Teacher_TestMarkingFrame',
					url : 'Teacher_TestMarkingFrame.html',
					pageParam : {
						rename : rename,
						vid : api.pageParam.vid,
						cid : api.pageParam.cid,
						pid : api.pageParam.pid,
						status : type,
						cuid : cuid,
						cjid : cjid,
						tid : tid,
						bewrite : api.pageParam.bewrite,
						is_dis_bewrite : api.pageParam.is_dis_bewrite,
						title : api.pageParam.title,
						type : api.pageParam.type,
					},
					vScrollBarEnabled : false,
					hScrollBarEnabled : false,
					slidBackEnabled : false,
					softInputMode : 'auto',
				});
			} else if (type == 1) {
				api.openWin({useWKWebView:true,
					name : 'Teacher_TestMarkingScoreFrame',
					url : 'Teacher_TestMarkingScoreFrame.html',
					pageParam : {
						rename : rename,
						vid : api.pageParam.vid,
						cid : api.pageParam.cid,
						pid : api.pageParam.pid,
						status : type,
						cuid : cuid,
						cjid : cjid,
						tid : tid,
						bewrite : api.pageParam.bewrite,
						is_dis_bewrite : api.pageParam.is_dis_bewrite,
						title : api.pageParam.title,
						type : api.pageParam.type,
					},
					vScrollBarEnabled : false,
					hScrollBarEnabled : false,
					slidBackEnabled : false,
					softInputMode : 'auto',
				});
			}
		}
	</script>
</html>